#! /bin/bash
export LANG=zh_CN.UTF-8
HIVE_HOME=/usr/bin/hive

${HIVE_HOME} -S -e "

CREATE DATABASE IF NOT EXISTS edu_dta;

CREATE TABLE edu_dta.dta_signin_count(
    class_date            STRING   COMMENT '上课日期',
    class_id              INT      COMMENT '班级id',
    morning_signin_count         INT      COMMENT '早上正常出勤人数',
    afternoon_signin_count       INT      COMMENT '下午正常出勤人数',
    evening_signin_count         INT      COMMENT '晚上正常出勤人数',
    morning_late_count    INT      COMMENT '早上迟到人数',
    afternoon_late_count  INT      COMMENT '下午迟到人数',
    evening_late_count    INT      COMMENT '晚上迟到人数'
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '/t'
STORED AS ORC
TBLPROPERTIES ('orc.compress' = 'snappy');


CREATE TABLE edu_dta.dta_leave_count(
    class_date            STRING   COMMENT '上课日期',
    class_id              INT      COMMENT '班级id',
    morning_leave_count   INT      COMMENT '上午请假人数',
    afternoon_leave_count INT      COMMENT '下午请假人数',
    evening_leave_count   INT      COMMENT '晚上请假人数'
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '/t'
STORED AS ORC
TBLPROPERTIES ('orc.compress' = 'snappy');


CREATE TABLE edu_dta.dta_absent_count(
    class_date            STRING   COMMENT '上课日期',
    class_id              INT      COMMENT '班级id',
    morning_absent_count   INT      COMMENT '上午旷课人数',
    afternoon_absent_count INT      COMMENT '下午旷课人数',
    evening_absent_count   INT      COMMENT '晚上旷课人数'
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '/t'
STORED AS ORC
TBLPROPERTIES ('orc.compress' = 'snappy');
"